package org.csu.mypetstore.persistence;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

public interface ManageProductMapper {
    @Insert("        SET foreign_key_checks = 0;\n" +
            "        insert into Product(productid,category,name,descn,image)\n" +
            "        values(#{productId},#{categoryId},#{name},#{description},#{image});\n" +
            "        SET foreign_key_checks = 1;")
    public void insertProduct(String productId,String categoryId,String name,String description,String image);

    @Update("update Product set category = #{categoryId},name = #{name},descn = #{description},image = #{image} where productid = #{productId}")
    public void updateProduct(String productId,String categoryId,String name,String description,String image);

    @Delete("        SET foreign_key_checks = 0;\n" +
            "        delete from Product  where productid = #{productId};\n" +
            "        delete from Item where productid = #{productId};\n" +
            "        SET foreign_key_checks = 1;")
    public void deleteProduct(String productId);
}
